package com.grj.parking.aa;


import com.grj.parking.domain.ParkingRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.EnumMap;
import java.util.Map;

/**
 * 停车策略工厂，负责根据车辆类型获取对应的策略
 */
@Component
public class ParkingStrategyFactory {

    // 缓存策略的映射关系
    @Autowired
    private ApplicationContext applicationContext;


    /**
     * 获取停车场策略
     * @param strategy 车辆类型
     * @return 对应的停车策略
     */
    public ParkingRecord getStrategy(String strategy, ParkingRecord parkingRecord) {
        ParkingStrategy s = applicationContext.getBean(strategy, ParkingStrategy.class);
        s.process(parkingRecord);
        if(parkingRecord.getVehicleType().equals("1")){
            s.process2(parkingRecord);
        }
        s.process3(parkingRecord);
        s.process4(parkingRecord);
        return null;
    }


}
